package by.bsu.android.lab.menu.options;


public class OptionsMenuActivity extends Activity {

    public static final byte OPEN_BTN = 1001;
    public static final byte SAVE_BTN = 1002;
    public static final byte EDIT_BTN = 1003;
    public static final byte QUIT_BNT = 1004;
    public static final byte FIND_BTN = 1005;
    public static final byte DELETE_BTN = 1006;

    
    public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

    }

    public boolean onCreateOptionsMenu(Menu menu) {

	menu.add(Menu.NONE, OPEN_BTN, Menu.NONE, "Open");
	menu.add(Menu.NONE, SAVE_BTN, Menu.NONE, "Save");
	menu.add(Menu.NONE, EDIT_BTN, Menu.NONE, "Edit");
	menu.add(Menu.NONE, QUIT_BNT, Menu.NONE, "Quit");
	menu.add(Menu.NONE, FIND_BTN, Menu.NONE, "Find");
	menu.add(Menu.NONE, DELETE_BTN, Menu.NONE, "Delete");

	return (super.onCreateOptionsMenu(menu));

    }

    public boolean onOptionsItemSelected(MenuItem item) {

	String message;
	switch (item.getItemId()) {
	case OPEN_BTN:
	    message = "Open item selected";
	    break;
	case SAVE_BTN:
	    message = "Save item selected";
	    break;
	case EDIT_BTN:
	    message = "Edit item selected";
	    break;
	case QUIT_BNT:
	    message = "Quit item selected";
	    break;
	case FIND_BTN:
	    message = "Find item selected";
	    break;
	case DELETE_BTN:
	    message = "Delete item selected";
	    break;
	default:
	    return false;

	Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
	toast.setGravity(Gravity.CENTER, 0, 0);
	toast.show();
	return true;

    }

}